package com.ruoyi.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.project.domain.entity.Dingdan;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 订单(Dingdan)表数据库访问层
 *
 * @author yanweichao
 * @since 2025-06-20
 */
@Mapper
public interface DingdanMapper extends BaseMapper<Dingdan> {


    @Select("select max(right(ywdh, 3)) dydh from t_dingdan where ywdh like CONCAT(#{prefix} ,'%')")
    String getMaxNo(String prefix);

    @Select("select max(right(zong_no, 3)) dydh from t_zong where zong_no like CONCAT(#{prefix} ,'%')")
    String getZongMaxNo(String prefix);

    @Insert("insert into t_zong (zong_no) select #{no} where not exists (select 1 from t_zong where zong_no = #{no})")
    Integer saveZongNo(String no);
}
